package com.ibeeking.found.file.rest.service.office.services.configurers.implementations;

import com.ibeeking.found.file.rest.service.office.documentserver.models.configurations.Customization;
import com.ibeeking.found.file.rest.service.office.documentserver.models.enums.Action;
import com.ibeeking.found.file.rest.service.office.entities.UserEntity;
import com.ibeeking.found.file.rest.service.office.services.configurers.CustomizationConfigurer;
import com.ibeeking.found.file.rest.service.office.services.configurers.wrappers.DefaultCustomizationWrapper;
import org.springframework.context.annotation.Primary;
import org.springframework.stereotype.Service;

@Service
@Primary
public class DefaultCustomizationConfigurer implements CustomizationConfigurer<DefaultCustomizationWrapper> {
    @Override
    public void configure(Customization customization, DefaultCustomizationWrapper wrapper) {  // define the customization configurer
        Action action = wrapper.getAction();  // get the action parameter from the customization wrapper
        UserEntity userEntity = wrapper.getUserEntity();
        customization.setSubmitForm(action.equals(Action.fillForms) && "1".equals(userEntity.getId()) && false);  // set the submitForm parameter to the customization config
    }
}
